#!/bin/bash
if (($#!=1)); then
    echo "未指定要结束的进程名，ps -A可查看"
    exit 1
fi

# 指定进程名
PROCESS_NAME=$1
PID=`ps -A | grep $PROCESS_NAME | awk '{print $1}'`
if [ $? -eq 0 ]; then
    echo "【$PROCESS_NAME】进程号：$PID"
else
    echo "未找到【$PROCESS_NAME】进程"
    exit 1
fi
# 强杀
kill -9 $PID

# 验证是否结束此进程
if [ $? -eq 0 ];then
    echo "强杀 $input1 成功"
else
    echo "强杀 $input1 失败"
    exit 1
fi